﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Security.Principal;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace MobileDesigner.App_Code
{
    public static class MvcHtmlHelpers
    {
        public static MvcHtmlString If(this MvcHtmlString value, bool evaluation)
        {
            return evaluation ? value : MvcHtmlString.Empty;
        }

        public static MvcHtmlString If(this MvcHtmlString value, IPrincipal user, List<string> roles)
        {
            var userRoles = Roles.GetRolesForUser(user.Identity.Name);
            return userRoles.Any(u => roles.Contains(u)) ? value : MvcHtmlString.Empty;
        }
    }
}